package fr.starn.meteo_widgets.JSonObject;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class DevicesProps {
//	SAMPLE received JSON
//	{
//		"coord":
//			{"lon":2.35,"lat":48.85},
//		"sys":{"message":0.1065,"country":"FR","sunrise":1405137640,"sunset":1405194717},
//		"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],
//		"base":"cmc stations",
//		"main":{"temp":296.15,"pressure":1015,"humidity":56,"temp_min":296.15,"temp_max":296.15},
//		"wind":{"speed":1.5,"deg":0},"clouds":{"all":75},"dt":1405175400,"id":2988507,"name":"Paris","cod":200}
	
	   private String town;
	   
	   private Sys sys;
	   private Weather[] weather;
	   private Main main;
	   
	   


	public String getTown() {
		return town;
	}

	public void setTown(String town) {
		this.town = town;
	}


	
	public Sys getSys() {
		return sys;
	}

	public void setSys(Sys sys) {
		this.sys = sys;
	}









	public Weather[] getWeather() {
		return weather;
	}

	public void setWeather(Weather[] weather) {
		this.weather = weather;
	}

	public Main getMain() {
		return main;
	}

	public void setMain(Main main) {
		this.main = main;
	}

	public static DevicesProps deserialize(String serializedString){
        Gson gson = new GsonBuilder().create();
        System.out.println(serializedString);
//        List<DeviceProps> result = new ArrayList<DeviceProps>();
        DevicesProps jsonProps = gson.fromJson(serializedString, DevicesProps.class);
//        for (DeviceProps jsonProp: jsonProps.getResult()){
//        	//if ( jsonProp.getName().equals(props.getDevice())){
//        		
//        		result.add(jsonProp);
////        	} else if ( props.getDevice()==null && jsonProp.getType().startsWith("Temp") || jsonProp.getSwitchType().equals("On/Off")){
////        		//result+=jsonProp.getName()+";";
////        		result.add(jsonProp);
////        	}
//        }
        return jsonProps;
	}
	
	public String serialize(){
		Gson gson = new GsonBuilder().create();
		return gson.toJson(this);
	}
}
